package com.agileai.bpm.controller.resource;

import org.logicalcobwebs.proxool.ProxoolFacade;

import com.agileai.bpm.bizmoduler.resource.WfDbconfigManage;
import com.agileai.domain.DataParam;
import com.agileai.hotweb.annotation.PageAction;
import com.agileai.hotweb.controller.core.StandardListHandler;
import com.agileai.hotweb.renders.AjaxRenderer;
import com.agileai.hotweb.renders.ViewRenderer;

public class WfDbconfigManageListHandler extends StandardListHandler{
	public WfDbconfigManageListHandler(){
		super();
		this.editHandlerClazz = WfDbconfigManageEditHandler.class;
		this.serviceId = buildServiceId(WfDbconfigManage.class);
	}
	protected void processPageAttributes(DataParam param) {
		
	}
	protected void initParameters(DataParam param) {
		
	}
	@PageAction
    public ViewRenderer reloadDatasources(DataParam param){
    	String responseText = FAIL;
    	try {
    		ProxoolFacade.shutdown();
    		boolean inited = getService().initializeDataSources();
    		if (inited){
    			responseText = SUCCESS;    			
    		}
		} catch (Exception e) {
			responseText = FAIL;
		}
    	return new AjaxRenderer(responseText);
    }
	protected WfDbconfigManage getService() {
		return (WfDbconfigManage)this.lookupService(this.getServiceId());
	}
}
